package p800;

import jdk.nashorn.internal.ir.debug.ObjectSizeCalculator;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.concurrent.Executors;

/**
 * @author pengjz <br>
 * @version 1.0 <br>
 * @description Leetcode_825 <br>
 * @date 2021/12/27 17:33 <br>
 */
public class Leetcode_825 {

    public int numFriendRequests(int[] ages) {
        int sum = 0;
        for (int i = 0; i < ages.length; i++) {
            for (int j = 0; j < ages.length; j++) {
                if (i != j) {
                    if (isFriend(ages[i], ages[j])) {
                        sum++;
                    }
                }
            }
        }
        return sum;
    }

    private boolean isFriend(int x, int y) {
        return !(
                y > x || ((double) y) <= (0.5 * (double) x + 7.0)
        );
    }



    public static void main(String[] args) {
        Leetcode_825 leetcode = new Leetcode_825();
        System.out.println(ObjectSizeCalculator.getObjectSize(leetcode));
        System.out.println(leetcode.numFriendRequests(new int[]{16, 16}));
        System.out.println(leetcode.numFriendRequests(new int[]{16, 17, 18}));
        System.out.println(leetcode.numFriendRequests(new int[]{20, 30, 100, 110, 120}));
    }
}
